﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="Customer_Maintain" CodeFile="Customer_Maintain.aspx.cs"
    MasterPageFile="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>客户信息</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2&services=true"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table id="wsd_inputtable">
        <tr>
            <td colspan="5" class="tabletitle">
                <font color="red"><b>提示:*为必填项</b></font>
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                &nbsp;门店编号
            </td>
            <td>
                <asp:TextBox ID="txtCustomerCode" class="default" runat="server"></asp:TextBox>
                <br />
                <asp:RequiredFieldValidator ID="rfv1" ControlToValidate="txtCustomerCode" runat="server"
                    ErrorMessage="门店编号不能为空!" Display="Dynamic"></asp:RequiredFieldValidator>
            </td>
            <td class="tablefield">
                <span class="keyword">*</span><asp:Literal ID="Literal6" runat="server" Text="<%$resources:language,lbl_CustomerName %>"></asp:Literal>
            </td>
            <td nowrap="nowrap">
                <asp:TextBox runat="server" class="default" ID="txtName" MaxLength="20"></asp:TextBox>
                <br />
                <asp:RequiredFieldValidator ID="rfv2" ControlToValidate="txtName" runat="server"
                    ErrorMessage="门店名称不能为空!" Display="Dynamic"></asp:RequiredFieldValidator>
            </td>
            <td rowspan="9">
                <div style="width: 500px; height: 500px; border: 1px solid gray" id="container" />
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                <span class="keyword">*</span><asp:Literal runat="server" Text="<%$resources:language,lbl_Address %>"></asp:Literal>
            </td>
            <td nowrap="nowrap">
                <asp:TextBox runat="server" class="default" ID="txtAddress" MaxLength="40" Width="148px"></asp:TextBox>
                <br />
                <asp:RequiredFieldValidator runat="server" ControlToValidate="txtAddress" ErrorMessage="地址不能为空!"
                    Display="Dynamic"></asp:RequiredFieldValidator>
            </td>
            <td class="tablefield">
                <asp:Literal runat="server" Text="<%$resources:language,lbl_ZipCode %>"></asp:Literal>
            </td>
            <td nowrap="nowrap">
                <asp:TextBox runat="server" class="default" ID="txtZipCode" MaxLength="6"></asp:TextBox>
                <br />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="<%$resources:language,lbl_Format %>"
                    ValidationExpression="^(\d{1,3}(,\d\d\d)*(\.\d+)?|\d+(\.\d+)?)$" ControlToValidate="txtZipCode"
                    Display="Dynamic"></asp:RegularExpressionValidator>
                <input id="txtHidOrg" type="hidden" runat="server" />
                <input id="txtHidUser" type="hidden" runat="server" />
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                联系电话
            </td>
            <td nowrap="nowrap">
                <asp:TextBox runat="server" class="default" ID="txtPhone" MaxLength="20"></asp:TextBox>
            </td>
            <td class="tablefield">
                联系人
            </td>
            <td nowrap="nowrap">
                <asp:TextBox runat="server" class="default" Width="148px" ID="txtContact" MaxLength="20"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                <span class="keyword">*</span>组织架构
            </td>
            <td nowrap="nowrap">
                <asp:TextBox ID="txtOrg" class="default" runat="server" onkeydown="alert('请选择组织架构');return false;"
                    CausesValidation="false" ontextchanged="txtOrg_TextChanged"></asp:TextBox>
                <img src="../Resources/Images/search.png" alt="查找" style="cursor: pointer;" onclick="openPopup('../System/PopupOrganization.aspx?NameControlId=<%# txtOrg.UniqueID %>&ValueControlId=<%# txtHidOrg.UniqueID %>&UserListControlID=<%# txtHidUser.UniqueID %>&SelectType=single','','300','500');" />
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtOrg"
                    ErrorMessage="组织架构不能为空!" Display="Dynamic"></asp:RequiredFieldValidator>
            </td>
            <td class="tablefield">
                <span class="keyword">* </span>
                <asp:Literal ID="Literal20" runat="server" Text="<%$resources:language,lbl_SalesChannel %>"></asp:Literal>
            </td>
            <td nowrap="nowrap">
                <asp:DropDownList runat="server" ID="ddlChannel" Width="148px">
                </asp:DropDownList>
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator10" ControlToValidate="ddlChannel"
                    runat="server" ErrorMessage="请选择销售渠道" Display="Dynamic"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                &nbsp;经度
            </td>
            <td>
                <asp:TextBox runat="server" class="default" ReadOnly="true" ID="txtLongitude" MaxLength="15"
                    Style="margin-bottom: 0px"></asp:TextBox>
            </td>
            <td class="tablefield">
                纬度
            </td>
            <td class="tablefield" style="text-align: left">
                <asp:TextBox runat="server" class="default" ReadOnly="true" ID="txtlatitude" MaxLength="15"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                客户等级
            </td>
            <td nowrap="nowrap">
                <asp:DropDownList runat="server" ID="ddlCustomerLevel" Width="150">
                </asp:DropDownList>
            </td>
            <td class="tablefield" style="vertical-align: middle">
                客户类型
            </td>
            <td nowrap="nowrap">
                <asp:DropDownList runat="server" ID="drpCustomerType" Width="150">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                <span class="keyword">* </span>指标组
            </td>
            <td nowrap="nowrap">
                <asp:DropDownList ID="ddlMeasures" runat="server" Width="150">
                </asp:DropDownList>
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="ddlMeasures"
                    runat="server" ErrorMessage="请选择指标组" Display="Dynamic"></asp:RequiredFieldValidator>
            </td>
            <td class="tablefield" style="vertical-align: middle">
                <asp:Literal ID="Literal26" runat="server" Text="<%$resources:language,lbl_Active %>"></asp:Literal>
            </td>
            <td nowrap="nowrap">
                <asp:CheckBox runat="server" ID="chxValid" Checked="true" onClick="if (!this.checked) {alert('注意: 失效客户会取消线路及覆盖中的存在')}" />
            </td>
        </tr>
        <tr>
            <td class="tablefield">组织架构地址</td>
            <td class="tablefield" colspan="3"><asp:TextBox Enabled="false" ID="txt_OrgAddress" 
                    runat="server" Width="286px"></asp:TextBox></td>
        </tr>
        <tr>
            <td class="tablefield">
                <span class="keyword">*</span>行政架构
            </td>
            <td colspan="3" align="left">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:DropDownList runat="server" ID="ddlProvince" AutoPostBack="True" OnSelectedIndexChanged="ddlProvince_SelectedIndexChanged">
                        </asp:DropDownList>
                        <asp:DropDownList runat="server" ID="ddlCity" AutoPostBack="True" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged">
                        </asp:DropDownList>
                        <asp:DropDownList runat="server" ID="ddlArea">
                        </asp:DropDownList>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="ddlCity" EventName="SelectedIndexChanged" />
                        <asp:AsyncPostBackTrigger ControlID="ddlProvince" EventName="SelectedIndexChanged" />
                    </Triggers>
                </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td class="tablefield">
                备注
            </td>
            <td nowrap="nowrap" colspan="3">
                <asp:TextBox runat="server" ID="txtRemark" TextMode="MultiLine" Width="98%" Height="100%"></asp:TextBox>
                <br />
                &nbsp; &nbsp;
            </td>
        </tr>
    </table>
    <table id="wsd_inputtable">
        <tr>
            <td width="100%" class="tabletitle">
                <asp:Literal ID="Literal40" runat="server" Text="<%$resources:language,lbl_Operation_Area %>"></asp:Literal>
            </td>
        </tr>
        <tr>
            <td class="buttonarea">
                <asp:Button ID="btnSave" runat="server" class="wsd_button2" Text="<%$resources:language,btn_Save %>"
                    OnClick="btnSave_Click" />&nbsp;<asp:Button ID="btnNewDis" runat="server" class="wsd_button2"
                        Text="经销商挂接" OnClick="btnNewDis_Click" Visible="False" />
                &nbsp;<asp:Button ID="btnCancel" runat="server" class="wsd_button2" Text="<%$resources:language,btn_Cancel %>"
                    CausesValidation="false" OnClick="btnCancel_Click" />
            </td>
        </tr>
    </table>
    <input type="hidden" runat="server" id="hd_org"/>
    <script type="text/javascript">

        var txtLongitude = $get("<%=txtLongitude.ClientID %>");
        var txtlatitude = $get("<%=txtlatitude.ClientID %>");
        var lng;
        var lat;
        lng = txtLongitude.value;
        lat = txtlatitude.value;

        if (lng == 0 && lat == 0) {
            //上海人民广场坐标
            lng = 121.48019;
            lat = 31.239428;
        }
        var map = new BMap.Map("container");
        var point = new BMap.Point(lng, lat);
        map.centerAndZoom(point, 19); //初始化地图显示坐标，参数1坐标，参数2缩放级别
        map.addControl(new BMap.NavigationControl()); //添加地图鱼骨控制
        //map.disableDragging();//禁止拖拽地图

        var marker = new BMap.Marker(point);  // 创建标注
        map.addOverlay(marker);              // 将标注添加到地图中
        //marker.enableDragging(true); // 设置标注可拖拽
        map.enableScrollWheelZoom();                  // 启用滚轮放大缩小。
        map.enableKeyboard();                         // 启用键盘操作。

        //map.setDefaultCursor("crosshair");//设置鼠标样式
        //start地图点击获取坐标
        var isremark = true;
        function remark(e) {
            if (isremark) {
                //map.removeControl(marker);
                map.clearOverlays();
                txtLongitude.value = e.point.lng
                txtlatitude.value = e.point.lat;
                marker.setPosition(e.point);
                map.addOverlay(marker);
            } else
                isremark = true;
        }
        map.addEventListener("click", remark);
        marker.addEventListener("click", function () {
            isremark = false; //点击标注本身时不重新标注

        });

        //end
    </script>
</asp:Content>
